var app = getApp();

Page({
  data: {
    isLoading: false,
    isNoData: true,
    fbList: []
  },
  onLoad: function() {
    var that = this;
    wx.showLoading({
      title: '加载中',
    });
    this.getList();
  },
  // 下拉刷新
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画。
    this.getList(); //重新获取反馈列表
    wx.hideNavigationBarLoading(); //隐藏导航条加载动画。
    wx.stopPullDownRefresh(); //停止当前页面下拉刷新。
  },
  // 获取反馈列表
  getList: function () {
    var that = this;
    wx.request({
      url: app.globalData.apiBaseUrl + '/trackBack/getUserBackList',
      header: {
        'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
        'FilterToken_MT': wx.getStorageSync("token")
      },
      method: 'GET',
      data: { telephone: wx.getStorageSync("telephone") },
      dataType: 'json',
      success: function (res) {
        res = res.data;
        if (res.code == 200) {
          that.setData({
            fbList: res.data,
            isLoading: true
          })
          if (res.data.length > 0) {
            that.setData({
              isNoData: true
            })
          } else {
            that.setData({
              isNoData: false
            })
          }
          wx.hideLoading();
        } else {
          wx.hideLoading();
          wx.showToast({
            title: res.msg,
            icon: 'none',
            duration: 3000
          })
        }
      }
    })
  }
});